var ce = Object.defineProperty;
var le = (s, e, t) => e in s ? ce(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
var p = (s, e, t) => le(s, typeof e != "symbol" ? e + "" : e, t);
import pe, { app as D, BrowserWindow as H, ipcMain as d, dialog as T, shell as G } from "electron";
import { fileURLToPath as he } from "node:url";
import v from "node:path";
import w from "path";
import fe from "child_process";
import F from "os";
import L from "fs";
import ue from "util";
import Y from "events";
import de from "http";
import ge from "https";
function me(s) {
  return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
}
const Q = L, A = w;
var ye = {
  findAndReadPackageJson: ve,
  tryReadJsonAt: S
};
function ve() {
  return S(Se()) || S(Ee()) || S(process.resourcesPath, "app.asar") || S(process.resourcesPath, "app") || S(process.cwd()) || { name: void 0, version: void 0 };
}
function S(...s) {
  if (s[0])
    try {
      const e = A.join(...s), t = be("package.json", e);
      if (!t)
        return;
      const r = JSON.parse(Q.readFileSync(t, "utf8")), n = (r == null ? void 0 : r.productName) || (r == null ? void 0 : r.name);
      return !n || n.toLowerCase() === "electron" ? void 0 : n ? { name: n, version: r == null ? void 0 : r.version } : void 0;
    } catch {
      return;
    }
}
function be(s, e) {
  let t = e;
  for (; ; ) {
    const r = A.parse(t), n = r.root, o = r.dir;
    if (Q.existsSync(A.join(t, s)))
      return A.resolve(A.join(t, s));
    if (t === n)
      return null;
    t = o;
  }
}
function Ee() {
  const s = process.argv.filter((t) => t.indexOf("--user-data-dir=") === 0);
  return s.length === 0 || typeof s[0] != "string" ? null : s[0].replace("--user-data-dir=", "");
}
function Se() {
  var s;
  try {
    return (s = require.main) == null ? void 0 : s.filename;
  } catch {
    return;
  }
}
const we = fe, b = F, E = w, Oe = ye;
let Ae = class {
  constructor() {
    p(this, "appName");
    p(this, "appPackageJson");
    p(this, "platform", process.platform);
  }
  getAppLogPath(e = this.getAppName()) {
    return this.platform === "darwin" ? E.join(this.getSystemPathHome(), "Library/Logs", e) : E.join(this.getAppUserDataPath(e), "logs");
  }
  getAppName() {
    var t;
    const e = this.appName || ((t = this.getAppPackageJson()) == null ? void 0 : t.name);
    if (!e)
      throw new Error(
        "electron-log can't determine the app name. It tried these methods:\n1. Use `electron.app.name`\n2. Use productName or name from the nearest package.json`\nYou can also set it through log.transports.file.setAppName()"
      );
    return e;
  }
  /**
   * @private
   * @returns {undefined}
   */
  getAppPackageJson() {
    return typeof this.appPackageJson != "object" && (this.appPackageJson = Oe.findAndReadPackageJson()), this.appPackageJson;
  }
  getAppUserDataPath(e = this.getAppName()) {
    return e ? E.join(this.getSystemPathAppData(), e) : void 0;
  }
  getAppVersion() {
    var e;
    return (e = this.getAppPackageJson()) == null ? void 0 : e.version;
  }
  getElectronLogPath() {
    return this.getAppLogPath();
  }
  getMacOsVersion() {
    const e = Number(b.release().split(".")[0]);
    return e <= 19 ? `10.${e - 4}` : e - 9;
  }
  /**
   * @protected
   * @returns {string}
   */
  getOsVersion() {
    let e = b.type().replace("_", " "), t = b.release();
    return e === "Darwin" && (e = "macOS", t = this.getMacOsVersion()), `${e} ${t}`;
  }
  /**
   * @return {PathVariables}
   */
  getPathVariables() {
    const e = this.getAppName(), t = this.getAppVersion(), r = this;
    return {
      appData: this.getSystemPathAppData(),
      appName: e,
      appVersion: t,
      get electronDefaultDir() {
        return r.getElectronLogPath();
      },
      home: this.getSystemPathHome(),
      libraryDefaultDir: this.getAppLogPath(e),
      libraryTemplate: this.getAppLogPath("{appName}"),
      temp: this.getSystemPathTemp(),
      userData: this.getAppUserDataPath(e)
    };
  }
  getSystemPathAppData() {
    const e = this.getSystemPathHome();
    switch (this.platform) {
      case "darwin":
        return E.join(e, "Library/Application Support");
      case "win32":
        return process.env.APPDATA || E.join(e, "AppData/Roaming");
      default:
        return process.env.XDG_CONFIG_HOME || E.join(e, ".config");
    }
  }
  getSystemPathHome() {
    var e;
    return ((e = b.homedir) == null ? void 0 : e.call(b)) || process.env.HOME;
  }
  getSystemPathTemp() {
    return b.tmpdir();
  }
  getVersions() {
    return {
      app: `${this.getAppName()} ${this.getAppVersion()}`,
      electron: void 0,
      os: this.getOsVersion()
    };
  }
  isDev() {
    return process.env.NODE_ENV === "development" || process.env.ELECTRON_IS_DEV === "1";
  }
  isElectron() {
    return !!process.versions.electron;
  }
  onAppEvent(e, t) {
  }
  onAppReady(e) {
    e();
  }
  onEveryWebContentsEvent(e, t) {
  }
  /**
   * Listen to async messages sent from opposite process
   * @param {string} channel
   * @param {function} listener
   */
  onIpc(e, t) {
  }
  onIpcInvoke(e, t) {
  }
  /**
   * @param {string} url
   * @param {Function} [logFunction]
   */
  openUrl(e, t = console.error) {
    const n = { darwin: "open", win32: "start", linux: "xdg-open" }[process.platform] || "xdg-open";
    we.exec(`${n} ${e}`, {}, (o) => {
      o && t(o);
    });
  }
  setAppName(e) {
    this.appName = e;
  }
  setPlatform(e) {
    this.platform = e;
  }
  setPreloadFileForSessions({
    filePath: e,
    // eslint-disable-line no-unused-vars
    includeFutureSession: t = !0,
    // eslint-disable-line no-unused-vars
    getSessions: r = () => []
    // eslint-disable-line no-unused-vars
  }) {
  }
  /**
   * Sent a message to opposite process
   * @param {string} channel
   * @param {any} message
   */
  sendIpc(e, t) {
  }
  showErrorBox(e, t) {
  }
};
var Le = Ae;
const $e = w, Pe = Le;
let De = class extends Pe {
  /**
   * @param {object} options
   * @param {typeof Electron} [options.electron]
   */
  constructor({ electron: t } = {}) {
    super();
    /**
     * @type {typeof Electron}
     */
    p(this, "electron");
    this.electron = t;
  }
  getAppName() {
    var r, n;
    let t;
    try {
      t = this.appName || ((r = this.electron.app) == null ? void 0 : r.name) || ((n = this.electron.app) == null ? void 0 : n.getName());
    } catch {
    }
    return t || super.getAppName();
  }
  getAppUserDataPath(t) {
    return this.getPath("userData") || super.getAppUserDataPath(t);
  }
  getAppVersion() {
    var r;
    let t;
    try {
      t = (r = this.electron.app) == null ? void 0 : r.getVersion();
    } catch {
    }
    return t || super.getAppVersion();
  }
  getElectronLogPath() {
    return this.getPath("logs") || super.getElectronLogPath();
  }
  /**
   * @private
   * @param {any} name
   * @returns {string|undefined}
   */
  getPath(t) {
    var r;
    try {
      return (r = this.electron.app) == null ? void 0 : r.getPath(t);
    } catch {
      return;
    }
  }
  getVersions() {
    return {
      app: `${this.getAppName()} ${this.getAppVersion()}`,
      electron: `Electron ${process.versions.electron}`,
      os: this.getOsVersion()
    };
  }
  getSystemPathAppData() {
    return this.getPath("appData") || super.getSystemPathAppData();
  }
  isDev() {
    var t;
    return ((t = this.electron.app) == null ? void 0 : t.isPackaged) !== void 0 ? !this.electron.app.isPackaged : typeof process.execPath == "string" ? $e.basename(process.execPath).toLowerCase().startsWith("electron") : super.isDev();
  }
  onAppEvent(t, r) {
    var n;
    return (n = this.electron.app) == null || n.on(t, r), () => {
      var o;
      (o = this.electron.app) == null || o.off(t, r);
    };
  }
  onAppReady(t) {
    var r, n, o;
    (r = this.electron.app) != null && r.isReady() ? t() : (n = this.electron.app) != null && n.once ? (o = this.electron.app) == null || o.once("ready", t) : t();
  }
  onEveryWebContentsEvent(t, r) {
    var o, i, a;
    return (i = (o = this.electron.webContents) == null ? void 0 : o.getAllWebContents()) == null || i.forEach((c) => {
      c.on(t, r);
    }), (a = this.electron.app) == null || a.on("web-contents-created", n), () => {
      var c, l;
      (c = this.electron.webContents) == null || c.getAllWebContents().forEach((h) => {
        h.off(t, r);
      }), (l = this.electron.app) == null || l.off("web-contents-created", n);
    };
    function n(c, l) {
      l.on(t, r);
    }
  }
  /**
   * Listen to async messages sent from opposite process
   * @param {string} channel
   * @param {function} listener
   */
  onIpc(t, r) {
    var n;
    (n = this.electron.ipcMain) == null || n.on(t, r);
  }
  onIpcInvoke(t, r) {
    var n, o;
    (o = (n = this.electron.ipcMain) == null ? void 0 : n.handle) == null || o.call(n, t, r);
  }
  /**
   * @param {string} url
   * @param {Function} [logFunction]
   */
  openUrl(t, r = console.error) {
    var n;
    (n = this.electron.shell) == null || n.openExternal(t).catch(r);
  }
  setPreloadFileForSessions({
    filePath: t,
    includeFutureSession: r = !0,
    getSessions: n = () => {
      var o;
      return [(o = this.electron.session) == null ? void 0 : o.defaultSession];
    }
  }) {
    for (const i of n().filter(Boolean))
      o(i);
    r && this.onAppEvent("session-created", (i) => {
      o(i);
    });
    function o(i) {
      typeof i.registerPreloadScript == "function" ? i.registerPreloadScript({
        filePath: t,
        id: "electron-log-preload",
        type: "frame"
      }) : i.setPreloads([...i.getPreloads(), t]);
    }
  }
  /**
   * Sent a message to opposite process
   * @param {string} channel
   * @param {any} message
   */
  sendIpc(t, r) {
    var n, o;
    (o = (n = this.electron.BrowserWindow) == null ? void 0 : n.getAllWindows()) == null || o.forEach((i) => {
      var a, c;
      ((a = i.webContents) == null ? void 0 : a.isDestroyed()) === !1 && ((c = i.webContents) == null ? void 0 : c.isCrashed()) === !1 && i.webContents.send(t, r);
    });
  }
  showErrorBox(t, r) {
    var n;
    (n = this.electron.dialog) == null || n.showErrorBox(t, r);
  }
};
var Fe = De, X = { exports: {} };
(function(s) {
  let e = {};
  try {
    e = require("electron");
  } catch {
  }
  e.ipcRenderer && t(e), s.exports = t;
  function t({ contextBridge: r, ipcRenderer: n }) {
    if (!n)
      return;
    n.on("__ELECTRON_LOG_IPC__", (i, a) => {
      window.postMessage({ cmd: "message", ...a });
    }), n.invoke("__ELECTRON_LOG__", { cmd: "getOptions" }).catch((i) => console.error(new Error(
      `electron-log isn't initialized in the main process. Please call log.initialize() before. ${i.message}`
    )));
    const o = {
      sendToMain(i) {
        try {
          n.send("__ELECTRON_LOG__", i);
        } catch (a) {
          console.error("electronLog.sendToMain ", a, "data:", i), n.send("__ELECTRON_LOG__", {
            cmd: "errorHandler",
            error: { message: a == null ? void 0 : a.message, stack: a == null ? void 0 : a.stack },
            errorName: "sendToMain"
          });
        }
      },
      log(...i) {
        o.sendToMain({ data: i, level: "info" });
      }
    };
    for (const i of ["error", "warn", "info", "verbose", "debug", "silly"])
      o[i] = (...a) => o.sendToMain({
        data: a,
        level: i
      });
    if (r && process.contextIsolated)
      try {
        r.exposeInMainWorld("__electronLog", o);
      } catch {
      }
    typeof window == "object" ? window.__electronLog = o : __electronLog = o;
  }
})(X);
var _e = X.exports;
const R = L, xe = F, M = w, je = _e;
let z = !1, W = !1;
var Ne = {
  initialize({
    externalApi: s,
    getSessions: e,
    includeFutureSession: t,
    logger: r,
    preload: n = !0,
    spyRendererConsole: o = !1
  }) {
    s.onAppReady(() => {
      try {
        n && Te({
          externalApi: s,
          getSessions: e,
          includeFutureSession: t,
          logger: r,
          preloadOption: n
        }), o && Ce({ externalApi: s, logger: r });
      } catch (i) {
        r.warn(i);
      }
    });
  }
};
function Te({
  externalApi: s,
  getSessions: e,
  includeFutureSession: t,
  logger: r,
  preloadOption: n
}) {
  let o = typeof n == "string" ? n : void 0;
  if (z) {
    r.warn(new Error("log.initialize({ preload }) already called").stack);
    return;
  }
  z = !0;
  try {
    o = M.resolve(
      __dirname,
      "../renderer/electron-log-preload.js"
    );
  } catch {
  }
  if (!o || !R.existsSync(o)) {
    o = M.join(
      s.getAppUserDataPath() || xe.tmpdir(),
      "electron-log-preload.js"
    );
    const i = `
      try {
        (${je.toString()})(require('electron'));
      } catch(e) {
        console.error(e);
      }
    `;
    R.writeFileSync(o, i, "utf8");
  }
  s.setPreloadFileForSessions({
    filePath: o,
    includeFutureSession: t,
    getSessions: e
  });
}
function Ce({ externalApi: s, logger: e }) {
  if (W) {
    e.warn(
      new Error("log.initialize({ spyRendererConsole }) already called").stack
    );
    return;
  }
  W = !0;
  const t = ["debug", "info", "warn", "error"];
  s.onEveryWebContentsEvent(
    "console-message",
    (r, n, o) => {
      e.processMessage({
        data: [o],
        level: t[n],
        variables: { processType: "renderer" }
      });
    }
  );
}
var Ie = Re;
function Re(s) {
  return Object.defineProperties(e, {
    defaultLabel: { value: "", writable: !0 },
    labelPadding: { value: !0, writable: !0 },
    maxLabelLength: { value: 0, writable: !0 },
    labelLength: {
      get() {
        switch (typeof e.labelPadding) {
          case "boolean":
            return e.labelPadding ? e.maxLabelLength : 0;
          case "number":
            return e.labelPadding;
          default:
            return 0;
        }
      }
    }
  });
  function e(t) {
    e.maxLabelLength = Math.max(e.maxLabelLength, t.length);
    const r = {};
    for (const n of s.levels)
      r[n] = (...o) => s.logData(o, { level: n, scope: t });
    return r.log = r.info, r;
  }
}
let Me = class {
  constructor({ processMessage: e }) {
    this.processMessage = e, this.buffer = [], this.enabled = !1, this.begin = this.begin.bind(this), this.commit = this.commit.bind(this), this.reject = this.reject.bind(this);
  }
  addMessage(e) {
    this.buffer.push(e);
  }
  begin() {
    this.enabled = [];
  }
  commit() {
    this.enabled = !1, this.buffer.forEach((e) => this.processMessage(e)), this.buffer = [];
  }
  reject() {
    this.enabled = !1, this.buffer = [];
  }
};
var ze = Me;
const We = Ie, ke = ze;
var y;
let Ue = (y = class {
  constructor({
    allowUnknownLevel: e = !1,
    dependencies: t = {},
    errorHandler: r,
    eventLogger: n,
    initializeFn: o,
    isDev: i = !1,
    levels: a = ["error", "warn", "info", "verbose", "debug", "silly"],
    logId: c,
    transportFactories: l = {},
    variables: h
  } = {}) {
    p(this, "dependencies", {});
    p(this, "errorHandler", null);
    p(this, "eventLogger", null);
    p(this, "functions", {});
    p(this, "hooks", []);
    p(this, "isDev", !1);
    p(this, "levels", null);
    p(this, "logId", null);
    p(this, "scope", null);
    p(this, "transports", {});
    p(this, "variables", {});
    this.addLevel = this.addLevel.bind(this), this.create = this.create.bind(this), this.initialize = this.initialize.bind(this), this.logData = this.logData.bind(this), this.processMessage = this.processMessage.bind(this), this.allowUnknownLevel = e, this.buffering = new ke(this), this.dependencies = t, this.initializeFn = o, this.isDev = i, this.levels = a, this.logId = c, this.scope = We(this), this.transportFactories = l, this.variables = h || {};
    for (const u of this.levels)
      this.addLevel(u, !1);
    this.log = this.info, this.functions.log = this.log, this.errorHandler = r, r == null || r.setOptions({ ...t, logFn: this.error }), this.eventLogger = n, n == null || n.setOptions({ ...t, logger: this });
    for (const [u, g] of Object.entries(l))
      this.transports[u] = g(this, t);
    y.instances[c] = this;
  }
  static getInstance({ logId: e }) {
    return this.instances[e] || this.instances.default;
  }
  addLevel(e, t = this.levels.length) {
    t !== !1 && this.levels.splice(t, 0, e), this[e] = (...r) => this.logData(r, { level: e }), this.functions[e] = this[e];
  }
  catchErrors(e) {
    return this.processMessage(
      {
        data: ["log.catchErrors is deprecated. Use log.errorHandler instead"],
        level: "warn"
      },
      { transports: ["console"] }
    ), this.errorHandler.startCatching(e);
  }
  create(e) {
    return typeof e == "string" && (e = { logId: e }), new y({
      dependencies: this.dependencies,
      errorHandler: this.errorHandler,
      initializeFn: this.initializeFn,
      isDev: this.isDev,
      transportFactories: this.transportFactories,
      variables: { ...this.variables },
      ...e
    });
  }
  compareLevels(e, t, r = this.levels) {
    const n = r.indexOf(e), o = r.indexOf(t);
    return o === -1 || n === -1 ? !0 : o <= n;
  }
  initialize(e = {}) {
    this.initializeFn({ logger: this, ...this.dependencies, ...e });
  }
  logData(e, t = {}) {
    this.buffering.enabled ? this.buffering.addMessage({ data: e, date: /* @__PURE__ */ new Date(), ...t }) : this.processMessage({ data: e, ...t });
  }
  processMessage(e, { transports: t = this.transports } = {}) {
    if (e.cmd === "errorHandler") {
      this.errorHandler.handle(e.error, {
        errorName: e.errorName,
        processType: "renderer",
        showDialog: !!e.showDialog
      });
      return;
    }
    let r = e.level;
    this.allowUnknownLevel || (r = this.levels.includes(e.level) ? e.level : "info");
    const n = {
      date: /* @__PURE__ */ new Date(),
      logId: this.logId,
      ...e,
      level: r,
      variables: {
        ...this.variables,
        ...e.variables
      }
    };
    for (const [o, i] of this.transportEntries(t))
      if (!(typeof i != "function" || i.level === !1) && this.compareLevels(i.level, e.level))
        try {
          const a = this.hooks.reduce((c, l) => c && l(c, i, o), n);
          a && i({ ...a, data: [...a.data] });
        } catch (a) {
          this.processInternalErrorFn(a);
        }
  }
  processInternalErrorFn(e) {
  }
  transportEntries(e = this.transports) {
    return (Array.isArray(e) ? e : Object.entries(e)).map((r) => {
      switch (typeof r) {
        case "string":
          return this.transports[r] ? [r, this.transports[r]] : null;
        case "function":
          return [r.name, r];
        default:
          return Array.isArray(r) ? r : null;
      }
    }).filter(Boolean);
  }
}, p(y, "instances", {}), y);
var Ve = Ue;
let Je = class {
  constructor({
    externalApi: e,
    logFn: t = void 0,
    onError: r = void 0,
    showDialog: n = void 0
  } = {}) {
    p(this, "externalApi");
    p(this, "isActive", !1);
    p(this, "logFn");
    p(this, "onError");
    p(this, "showDialog", !0);
    this.createIssue = this.createIssue.bind(this), this.handleError = this.handleError.bind(this), this.handleRejection = this.handleRejection.bind(this), this.setOptions({ externalApi: e, logFn: t, onError: r, showDialog: n }), this.startCatching = this.startCatching.bind(this), this.stopCatching = this.stopCatching.bind(this);
  }
  handle(e, {
    logFn: t = this.logFn,
    onError: r = this.onError,
    processType: n = "browser",
    showDialog: o = this.showDialog,
    errorName: i = ""
  } = {}) {
    var a;
    e = Be(e);
    try {
      if (typeof r == "function") {
        const c = ((a = this.externalApi) == null ? void 0 : a.getVersions()) || {}, l = this.createIssue;
        if (r({
          createIssue: l,
          error: e,
          errorName: i,
          processType: n,
          versions: c
        }) === !1)
          return;
      }
      i ? t(i, e) : t(e), o && !i.includes("rejection") && this.externalApi && this.externalApi.showErrorBox(
        `A JavaScript error occurred in the ${n} process`,
        e.stack
      );
    } catch {
      console.error(e);
    }
  }
  setOptions({ externalApi: e, logFn: t, onError: r, showDialog: n }) {
    typeof e == "object" && (this.externalApi = e), typeof t == "function" && (this.logFn = t), typeof r == "function" && (this.onError = r), typeof n == "boolean" && (this.showDialog = n);
  }
  startCatching({ onError: e, showDialog: t } = {}) {
    this.isActive || (this.isActive = !0, this.setOptions({ onError: e, showDialog: t }), process.on("uncaughtException", this.handleError), process.on("unhandledRejection", this.handleRejection));
  }
  stopCatching() {
    this.isActive = !1, process.removeListener("uncaughtException", this.handleError), process.removeListener("unhandledRejection", this.handleRejection);
  }
  createIssue(e, t) {
    var r;
    (r = this.externalApi) == null || r.openUrl(
      `${e}?${new URLSearchParams(t).toString()}`
    );
  }
  handleError(e) {
    this.handle(e, { errorName: "Unhandled" });
  }
  handleRejection(e) {
    const t = e instanceof Error ? e : new Error(JSON.stringify(e));
    this.handle(t, { errorName: "Unhandled rejection" });
  }
};
function Be(s) {
  if (s instanceof Error)
    return s;
  if (s && typeof s == "object") {
    if (s.message)
      return Object.assign(new Error(s.message), s);
    try {
      return new Error(JSON.stringify(s));
    } catch (e) {
      return new Error(`Couldn't normalize error ${String(s)}: ${e}`);
    }
  }
  return new Error(`Can't normalize error ${String(s)}`);
}
var qe = Je;
let He = class {
  constructor(e = {}) {
    p(this, "disposers", []);
    p(this, "format", "{eventSource}#{eventName}:");
    p(this, "formatters", {
      app: {
        "certificate-error": ({ args: e }) => this.arrayToObject(e.slice(1, 4), [
          "url",
          "error",
          "certificate"
        ]),
        "child-process-gone": ({ args: e }) => e.length === 1 ? e[0] : e,
        "render-process-gone": ({ args: [e, t] }) => t && typeof t == "object" ? { ...t, ...this.getWebContentsDetails(e) } : []
      },
      webContents: {
        "console-message": ({ args: [e, t, r, n] }) => {
          if (!(e < 3))
            return { message: t, source: `${n}:${r}` };
        },
        "did-fail-load": ({ args: e }) => this.arrayToObject(e, [
          "errorCode",
          "errorDescription",
          "validatedURL",
          "isMainFrame",
          "frameProcessId",
          "frameRoutingId"
        ]),
        "did-fail-provisional-load": ({ args: e }) => this.arrayToObject(e, [
          "errorCode",
          "errorDescription",
          "validatedURL",
          "isMainFrame",
          "frameProcessId",
          "frameRoutingId"
        ]),
        "plugin-crashed": ({ args: e }) => this.arrayToObject(e, ["name", "version"]),
        "preload-error": ({ args: e }) => this.arrayToObject(e, ["preloadPath", "error"])
      }
    });
    p(this, "events", {
      app: {
        "certificate-error": !0,
        "child-process-gone": !0,
        "render-process-gone": !0
      },
      webContents: {
        // 'console-message': true,
        "did-fail-load": !0,
        "did-fail-provisional-load": !0,
        "plugin-crashed": !0,
        "preload-error": !0,
        unresponsive: !0
      }
    });
    p(this, "externalApi");
    p(this, "level", "error");
    p(this, "scope", "");
    this.setOptions(e);
  }
  setOptions({
    events: e,
    externalApi: t,
    level: r,
    logger: n,
    format: o,
    formatters: i,
    scope: a
  }) {
    typeof e == "object" && (this.events = e), typeof t == "object" && (this.externalApi = t), typeof r == "string" && (this.level = r), typeof n == "object" && (this.logger = n), (typeof o == "string" || typeof o == "function") && (this.format = o), typeof i == "object" && (this.formatters = i), typeof a == "string" && (this.scope = a);
  }
  startLogging(e = {}) {
    this.setOptions(e), this.disposeListeners();
    for (const t of this.getEventNames(this.events.app))
      this.disposers.push(
        this.externalApi.onAppEvent(t, (...r) => {
          this.handleEvent({ eventSource: "app", eventName: t, handlerArgs: r });
        })
      );
    for (const t of this.getEventNames(this.events.webContents))
      this.disposers.push(
        this.externalApi.onEveryWebContentsEvent(
          t,
          (...r) => {
            this.handleEvent(
              { eventSource: "webContents", eventName: t, handlerArgs: r }
            );
          }
        )
      );
  }
  stopLogging() {
    this.disposeListeners();
  }
  arrayToObject(e, t) {
    const r = {};
    return t.forEach((n, o) => {
      r[n] = e[o];
    }), e.length > t.length && (r.unknownArgs = e.slice(t.length)), r;
  }
  disposeListeners() {
    this.disposers.forEach((e) => e()), this.disposers = [];
  }
  formatEventLog({ eventName: e, eventSource: t, handlerArgs: r }) {
    var h;
    const [n, ...o] = r;
    if (typeof this.format == "function")
      return this.format({ args: o, event: n, eventName: e, eventSource: t });
    const i = (h = this.formatters[t]) == null ? void 0 : h[e];
    let a = o;
    if (typeof i == "function" && (a = i({ args: o, event: n, eventName: e, eventSource: t })), !a)
      return;
    const c = {};
    return Array.isArray(a) ? c.args = a : typeof a == "object" && Object.assign(c, a), t === "webContents" && Object.assign(c, this.getWebContentsDetails(n == null ? void 0 : n.sender)), [this.format.replace("{eventSource}", t === "app" ? "App" : "WebContents").replace("{eventName}", e), c];
  }
  getEventNames(e) {
    return !e || typeof e != "object" ? [] : Object.entries(e).filter(([t, r]) => r).map(([t]) => t);
  }
  getWebContentsDetails(e) {
    if (!(e != null && e.loadURL))
      return {};
    try {
      return {
        webContents: {
          id: e.id,
          url: e.getURL()
        }
      };
    } catch {
      return {};
    }
  }
  handleEvent({ eventName: e, eventSource: t, handlerArgs: r }) {
    var o;
    const n = this.formatEventLog({ eventName: e, eventSource: t, handlerArgs: r });
    if (n) {
      const i = this.scope ? this.logger.scope(this.scope) : this.logger;
      (o = i == null ? void 0 : i[this.level]) == null || o.call(i, ...n);
    }
  }
};
var Ge = He, $ = { transform: Ye };
function Ye({
  logger: s,
  message: e,
  transport: t,
  initialData: r = (e == null ? void 0 : e.data) || [],
  transforms: n = t == null ? void 0 : t.transforms
}) {
  return n.reduce((o, i) => typeof i == "function" ? i({ data: o, logger: s, message: e, transport: t }) : o, r);
}
const { transform: Qe } = $;
var Z = {
  concatFirstStringElements: Xe,
  format({ message: s, logger: e, transport: t, data: r = s == null ? void 0 : s.data }) {
    switch (typeof t.format) {
      case "string":
        return Qe({
          message: s,
          logger: e,
          transforms: [et, Ke, tt],
          transport: t,
          initialData: [t.format, ...r]
        });
      case "function":
        return t.format({
          data: r,
          level: (s == null ? void 0 : s.level) || "info",
          logger: e,
          message: s,
          transport: t
        });
      default:
        return r;
    }
  }
};
function Xe({ data: s }) {
  return typeof s[0] != "string" || typeof s[1] != "string" || s[0].match(/%[1cdfiOos]/) ? s : [`${s[0]} ${s[1]}`, ...s.slice(2)];
}
function Ze(s) {
  const e = Math.abs(s), t = s > 0 ? "-" : "+", r = Math.floor(e / 60).toString().padStart(2, "0"), n = (e % 60).toString().padStart(2, "0");
  return `${t}${r}:${n}`;
}
function Ke({ data: s, logger: e, message: t }) {
  const { defaultLabel: r, labelLength: n } = (e == null ? void 0 : e.scope) || {}, o = s[0];
  let i = t.scope;
  i || (i = r);
  let a;
  return i === "" ? a = n > 0 ? "".padEnd(n + 3) : "" : typeof i == "string" ? a = ` (${i})`.padEnd(n + 3) : a = "", s[0] = o.replace("{scope}", a), s;
}
function et({ data: s, message: e }) {
  let t = s[0];
  if (typeof t != "string")
    return s;
  t = t.replace("{level}]", `${e.level}]`.padEnd(6, " "));
  const r = e.date || /* @__PURE__ */ new Date();
  return s[0] = t.replace(/\{(\w+)}/g, (n, o) => {
    var i;
    switch (o) {
      case "level":
        return e.level || "info";
      case "logId":
        return e.logId;
      case "y":
        return r.getFullYear().toString(10);
      case "m":
        return (r.getMonth() + 1).toString(10).padStart(2, "0");
      case "d":
        return r.getDate().toString(10).padStart(2, "0");
      case "h":
        return r.getHours().toString(10).padStart(2, "0");
      case "i":
        return r.getMinutes().toString(10).padStart(2, "0");
      case "s":
        return r.getSeconds().toString(10).padStart(2, "0");
      case "ms":
        return r.getMilliseconds().toString(10).padStart(3, "0");
      case "z":
        return Ze(r.getTimezoneOffset());
      case "iso":
        return r.toISOString();
      default:
        return ((i = e.variables) == null ? void 0 : i[o]) || n;
    }
  }).trim(), s;
}
function tt({ data: s }) {
  const e = s[0];
  if (typeof e != "string")
    return s;
  if (e.lastIndexOf("{text}") === e.length - 6)
    return s[0] = e.replace(/\s?{text}/, ""), s[0] === "" && s.shift(), s;
  const r = e.split("{text}");
  let n = [];
  return r[0] !== "" && n.push(r[0]), n = n.concat(s.slice(1)), r[1] !== "" && n.push(r[1]), n;
}
var K = { exports: {} };
(function(s) {
  const e = ue;
  s.exports = {
    serialize: r,
    maxDepth({ data: n, transport: o, depth: i = (o == null ? void 0 : o.depth) ?? 6 }) {
      if (!n)
        return n;
      if (i < 1)
        return Array.isArray(n) ? "[array]" : typeof n == "object" && n ? "[object]" : n;
      if (Array.isArray(n))
        return n.map((c) => s.exports.maxDepth({
          data: c,
          depth: i - 1
        }));
      if (typeof n != "object" || n && typeof n.toISOString == "function")
        return n;
      if (n === null)
        return null;
      if (n instanceof Error)
        return n;
      const a = {};
      for (const c in n)
        Object.prototype.hasOwnProperty.call(n, c) && (a[c] = s.exports.maxDepth({
          data: n[c],
          depth: i - 1
        }));
      return a;
    },
    toJSON({ data: n }) {
      return JSON.parse(JSON.stringify(n, t()));
    },
    toString({ data: n, transport: o }) {
      const i = (o == null ? void 0 : o.inspectOptions) || {}, a = n.map((c) => {
        if (c !== void 0)
          try {
            const l = JSON.stringify(c, t(), "  ");
            return l === void 0 ? void 0 : JSON.parse(l);
          } catch {
            return c;
          }
      });
      return e.formatWithOptions(i, ...a);
    }
  };
  function t(n = {}) {
    const o = /* @__PURE__ */ new WeakSet();
    return function(i, a) {
      if (typeof a == "object" && a !== null) {
        if (o.has(a))
          return;
        o.add(a);
      }
      return r(i, a, n);
    };
  }
  function r(n, o, i = {}) {
    const a = (i == null ? void 0 : i.serializeMapAndSet) !== !1;
    return o instanceof Error ? o.stack : o && (typeof o == "function" ? `[function] ${o.toString()}` : o instanceof Date ? o.toISOString() : a && o instanceof Map && Object.fromEntries ? Object.fromEntries(o) : a && o instanceof Set && Array.from ? Array.from(o) : o);
  }
})(K);
var _ = K.exports, C = {
  applyAnsiStyles({ data: s }) {
    return k(s, rt, nt);
  },
  removeStyles({ data: s }) {
    return k(s, () => "");
  }
};
const ee = {
  unset: "\x1B[0m",
  black: "\x1B[30m",
  red: "\x1B[31m",
  green: "\x1B[32m",
  yellow: "\x1B[33m",
  blue: "\x1B[34m",
  magenta: "\x1B[35m",
  cyan: "\x1B[36m",
  white: "\x1B[37m",
  gray: "\x1B[90m"
};
function rt(s) {
  const e = s.replace(/color:\s*(\w+).*/, "$1").toLowerCase();
  return ee[e] || "";
}
function nt(s) {
  return s + ee.unset;
}
function k(s, e, t) {
  const r = {};
  return s.reduce((n, o, i, a) => {
    if (r[i])
      return n;
    if (typeof o == "string") {
      let c = i, l = !1;
      o = o.replace(/%[1cdfiOos]/g, (h) => {
        if (c += 1, h !== "%c")
          return h;
        const u = a[c];
        return typeof u == "string" ? (r[c] = !0, l = !0, e(u, o)) : h;
      }), l && t && (o = t(o));
    }
    return n.push(o), n;
  }, []);
}
const {
  concatFirstStringElements: st,
  format: ot
} = Z, { maxDepth: it, toJSON: at } = _, {
  applyAnsiStyles: ct,
  removeStyles: lt
} = C, { transform: pt } = $, U = {
  error: console.error,
  warn: console.warn,
  info: console.info,
  verbose: console.info,
  debug: console.debug,
  silly: console.debug,
  log: console.log
};
var ht = re;
const ft = process.platform === "win32" ? ">" : "›", te = `%c{h}:{i}:{s}.{ms}{scope}%c ${ft} {text}`;
Object.assign(re, {
  DEFAULT_FORMAT: te
});
function re(s) {
  return Object.assign(e, {
    colorMap: {
      error: "red",
      warn: "yellow",
      info: "cyan",
      verbose: "unset",
      debug: "gray",
      silly: "gray",
      default: "unset"
    },
    format: te,
    level: "silly",
    transforms: [
      ut,
      ot,
      gt,
      st,
      it,
      at
    ],
    useStyles: process.env.FORCE_STYLES,
    writeFn({ message: t }) {
      (U[t.level] || U.info)(...t.data);
    }
  });
  function e(t) {
    const r = pt({ logger: s, message: t, transport: e });
    e.writeFn({
      message: { ...t, data: r }
    });
  }
}
function ut({ data: s, message: e, transport: t }) {
  return typeof t.format != "string" || !t.format.includes("%c") ? s : [
    `color:${mt(e.level, t)}`,
    "color:unset",
    ...s
  ];
}
function dt(s, e) {
  if (typeof s == "boolean")
    return s;
  const r = e === "error" || e === "warn" ? process.stderr : process.stdout;
  return r && r.isTTY;
}
function gt(s) {
  const { message: e, transport: t } = s;
  return (dt(t.useStyles, e.level) ? ct : lt)(s);
}
function mt(s, e) {
  return e.colorMap[s] || e.colorMap.default;
}
const yt = Y, m = L, V = F;
let vt = class extends yt {
  constructor({
    path: t,
    writeOptions: r = { encoding: "utf8", flag: "a", mode: 438 },
    writeAsync: n = !1
  }) {
    super();
    p(this, "asyncWriteQueue", []);
    p(this, "bytesWritten", 0);
    p(this, "hasActiveAsyncWriting", !1);
    p(this, "path", null);
    p(this, "initialSize");
    p(this, "writeOptions", null);
    p(this, "writeAsync", !1);
    this.path = t, this.writeOptions = r, this.writeAsync = n;
  }
  get size() {
    return this.getSize();
  }
  clear() {
    try {
      return m.writeFileSync(this.path, "", {
        mode: this.writeOptions.mode,
        flag: "w"
      }), this.reset(), !0;
    } catch (t) {
      return t.code === "ENOENT" ? !0 : (this.emit("error", t, this), !1);
    }
  }
  crop(t) {
    try {
      const r = bt(this.path, t || 4096);
      this.clear(), this.writeLine(`[log cropped]${V.EOL}${r}`);
    } catch (r) {
      this.emit(
        "error",
        new Error(`Couldn't crop file ${this.path}. ${r.message}`),
        this
      );
    }
  }
  getSize() {
    if (this.initialSize === void 0)
      try {
        const t = m.statSync(this.path);
        this.initialSize = t.size;
      } catch {
        this.initialSize = 0;
      }
    return this.initialSize + this.bytesWritten;
  }
  increaseBytesWrittenCounter(t) {
    this.bytesWritten += Buffer.byteLength(t, this.writeOptions.encoding);
  }
  isNull() {
    return !1;
  }
  nextAsyncWrite() {
    const t = this;
    if (this.hasActiveAsyncWriting || this.asyncWriteQueue.length === 0)
      return;
    const r = this.asyncWriteQueue.join("");
    this.asyncWriteQueue = [], this.hasActiveAsyncWriting = !0, m.writeFile(this.path, r, this.writeOptions, (n) => {
      t.hasActiveAsyncWriting = !1, n ? t.emit(
        "error",
        new Error(`Couldn't write to ${t.path}. ${n.message}`),
        this
      ) : t.increaseBytesWrittenCounter(r), t.nextAsyncWrite();
    });
  }
  reset() {
    this.initialSize = void 0, this.bytesWritten = 0;
  }
  toString() {
    return this.path;
  }
  writeLine(t) {
    if (t += V.EOL, this.writeAsync) {
      this.asyncWriteQueue.push(t), this.nextAsyncWrite();
      return;
    }
    try {
      m.writeFileSync(this.path, t, this.writeOptions), this.increaseBytesWrittenCounter(t);
    } catch (r) {
      this.emit(
        "error",
        new Error(`Couldn't write to ${this.path}. ${r.message}`),
        this
      );
    }
  }
};
var ne = vt;
function bt(s, e) {
  const t = Buffer.alloc(e), r = m.statSync(s), n = Math.min(r.size, e), o = Math.max(0, r.size - e), i = m.openSync(s, "r"), a = m.readSync(i, t, 0, n, o);
  return m.closeSync(i), t.toString("utf8", 0, a);
}
const Et = ne;
let St = class extends Et {
  clear() {
  }
  crop() {
  }
  getSize() {
    return 0;
  }
  isNull() {
    return !0;
  }
  writeLine() {
  }
};
var wt = St;
const Ot = Y, J = L, B = w, At = ne, Lt = wt;
let $t = class extends Ot {
  constructor() {
    super();
    p(this, "store", {});
    this.emitError = this.emitError.bind(this);
  }
  /**
   * Provide a File object corresponding to the filePath
   * @param {string} filePath
   * @param {WriteOptions} [writeOptions]
   * @param {boolean} [writeAsync]
   * @return {File}
   */
  provide({ filePath: t, writeOptions: r = {}, writeAsync: n = !1 }) {
    let o;
    try {
      if (t = B.resolve(t), this.store[t])
        return this.store[t];
      o = this.createFile({ filePath: t, writeOptions: r, writeAsync: n });
    } catch (i) {
      o = new Lt({ path: t }), this.emitError(i, o);
    }
    return o.on("error", this.emitError), this.store[t] = o, o;
  }
  /**
   * @param {string} filePath
   * @param {WriteOptions} writeOptions
   * @param {boolean} async
   * @return {File}
   * @private
   */
  createFile({ filePath: t, writeOptions: r, writeAsync: n }) {
    return this.testFileWriting({ filePath: t, writeOptions: r }), new At({ path: t, writeOptions: r, writeAsync: n });
  }
  /**
   * @param {Error} error
   * @param {File} file
   * @private
   */
  emitError(t, r) {
    this.emit("error", t, r);
  }
  /**
   * @param {string} filePath
   * @param {WriteOptions} writeOptions
   * @private
   */
  testFileWriting({ filePath: t, writeOptions: r }) {
    J.mkdirSync(B.dirname(t), { recursive: !0 }), J.writeFileSync(t, "", { flag: "a", mode: r.mode });
  }
};
var Pt = $t;
const P = L, Dt = F, O = w, Ft = Pt, { transform: _t } = $, { removeStyles: xt } = C, {
  format: jt,
  concatFirstStringElements: Nt
} = Z, { toString: Tt } = _;
var Ct = Rt;
const It = new Ft();
function Rt(s, { registry: e = It, externalApi: t } = {}) {
  let r;
  return e.listenerCount("error") < 1 && e.on("error", (l, h) => {
    i(`Can't write to ${h}`, l);
  }), Object.assign(n, {
    fileName: Mt(s.variables.processType),
    format: "[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}]{scope} {text}",
    getFile: a,
    inspectOptions: { depth: 5 },
    level: "silly",
    maxSize: 1024 ** 2,
    readAllLogs: c,
    sync: !0,
    transforms: [xt, jt, Nt, Tt],
    writeOptions: { flag: "a", mode: 438, encoding: "utf8" },
    archiveLogFn(l) {
      const h = l.toString(), u = O.parse(h);
      try {
        P.renameSync(h, O.join(u.dir, `${u.name}.old${u.ext}`));
      } catch (g) {
        i("Could not rotate log", g);
        const ae = Math.round(n.maxSize / 4);
        l.crop(Math.min(ae, 256 * 1024));
      }
    },
    resolvePathFn(l) {
      return O.join(l.libraryDefaultDir, l.fileName);
    },
    setAppName(l) {
      s.dependencies.externalApi.setAppName(l);
    }
  });
  function n(l) {
    const h = a(l);
    n.maxSize > 0 && h.size > n.maxSize && (n.archiveLogFn(h), h.reset());
    const g = _t({ logger: s, message: l, transport: n });
    h.writeLine(g);
  }
  function o() {
    r || (r = Object.create(
      Object.prototype,
      {
        ...Object.getOwnPropertyDescriptors(
          t.getPathVariables()
        ),
        fileName: {
          get() {
            return n.fileName;
          },
          enumerable: !0
        }
      }
    ), typeof n.archiveLog == "function" && (n.archiveLogFn = n.archiveLog, i("archiveLog is deprecated. Use archiveLogFn instead")), typeof n.resolvePath == "function" && (n.resolvePathFn = n.resolvePath, i("resolvePath is deprecated. Use resolvePathFn instead")));
  }
  function i(l, h = null, u = "error") {
    const g = [`electron-log.transports.file: ${l}`];
    h && g.push(h), s.transports.console({ data: g, date: /* @__PURE__ */ new Date(), level: u });
  }
  function a(l) {
    o();
    const h = n.resolvePathFn(r, l);
    return e.provide({
      filePath: h,
      writeAsync: !n.sync,
      writeOptions: n.writeOptions
    });
  }
  function c({ fileFilter: l = (h) => h.endsWith(".log") } = {}) {
    o();
    const h = O.dirname(n.resolvePathFn(r));
    return P.existsSync(h) ? P.readdirSync(h).map((u) => O.join(h, u)).filter(l).map((u) => {
      try {
        return {
          path: u,
          lines: P.readFileSync(u, "utf8").split(Dt.EOL)
        };
      } catch {
        return null;
      }
    }).filter(Boolean) : [];
  }
}
function Mt(s = process.type) {
  switch (s) {
    case "renderer":
      return "renderer.log";
    case "worker":
      return "worker.log";
    default:
      return "main.log";
  }
}
const { maxDepth: zt, toJSON: Wt } = _, { transform: kt } = $;
var Ut = Vt;
function Vt(s, { externalApi: e }) {
  return Object.assign(t, {
    depth: 3,
    eventId: "__ELECTRON_LOG_IPC__",
    level: s.isDev ? "silly" : !1,
    transforms: [Wt, zt]
  }), e != null && e.isElectron() ? t : void 0;
  function t(r) {
    var n;
    ((n = r == null ? void 0 : r.variables) == null ? void 0 : n.processType) !== "renderer" && (e == null || e.sendIpc(t.eventId, {
      ...r,
      data: kt({ logger: s, message: r, transport: t })
    }));
  }
}
const Jt = de, Bt = ge, { transform: qt } = $, { removeStyles: Ht } = C, { toJSON: Gt, maxDepth: Yt } = _;
var Qt = Xt;
function Xt(s) {
  return Object.assign(e, {
    client: { name: "electron-application" },
    depth: 6,
    level: !1,
    requestOptions: {},
    transforms: [Ht, Gt, Yt],
    makeBodyFn({ message: t }) {
      return JSON.stringify({
        client: e.client,
        data: t.data,
        date: t.date.getTime(),
        level: t.level,
        scope: t.scope,
        variables: t.variables
      });
    },
    processErrorFn({ error: t }) {
      s.processMessage(
        {
          data: [`electron-log: can't POST ${e.url}`, t],
          level: "warn"
        },
        { transports: ["console", "file"] }
      );
    },
    sendRequestFn({ serverUrl: t, requestOptions: r, body: n }) {
      const i = (t.startsWith("https:") ? Bt : Jt).request(t, {
        method: "POST",
        ...r,
        headers: {
          "Content-Type": "application/json",
          "Content-Length": n.length,
          ...r.headers
        }
      });
      return i.write(n), i.end(), i;
    }
  });
  function e(t) {
    if (!e.url)
      return;
    const r = e.makeBodyFn({
      logger: s,
      message: { ...t, data: qt({ logger: s, message: t, transport: e }) },
      transport: e
    }), n = e.sendRequestFn({
      serverUrl: e.url,
      requestOptions: e.requestOptions,
      body: Buffer.from(r, "utf8")
    });
    n.on("error", (o) => e.processErrorFn({
      error: o,
      logger: s,
      message: t,
      request: n,
      transport: e
    }));
  }
}
const q = Ve, Zt = qe, Kt = Ge, er = ht, tr = Ct, rr = Ut, nr = Qt;
var sr = or;
function or({ dependencies: s, initializeFn: e }) {
  var r;
  const t = new q({
    dependencies: s,
    errorHandler: new Zt(),
    eventLogger: new Kt(),
    initializeFn: e,
    isDev: (r = s.externalApi) == null ? void 0 : r.isDev(),
    logId: "default",
    transportFactories: {
      console: er,
      file: tr,
      ipc: rr,
      remote: nr
    },
    variables: {
      processType: "main"
    }
  });
  return t.default = t, t.Logger = q, t.processInternalErrorFn = (n) => {
    t.transports.console.writeFn({
      message: {
        data: ["Unhandled electron-log error", n],
        level: "error"
      }
    });
  }, t;
}
const ir = pe, ar = Fe, { initialize: cr } = Ne, lr = sr, I = new ar({ electron: ir }), x = lr({
  dependencies: { externalApi: I },
  initializeFn: cr
});
var pr = x;
I.onIpc("__ELECTRON_LOG__", (s, e) => {
  e.scope && x.Logger.getInstance(e).scope(e.scope);
  const t = new Date(e.date);
  se({
    ...e,
    date: t.getTime() ? t : /* @__PURE__ */ new Date()
  });
});
I.onIpcInvoke("__ELECTRON_LOG__", (s, { cmd: e = "", logId: t }) => {
  switch (e) {
    case "getOptions":
      return {
        levels: x.Logger.getInstance({ logId: t }).levels,
        logId: t
      };
    default:
      return se({ data: [`Unknown cmd '${e}'`], level: "error" }), {};
  }
});
function se(s) {
  var e;
  (e = x.Logger.getInstance(s)) == null || e.processMessage(s);
}
const hr = pr;
var fr = hr;
const j = /* @__PURE__ */ me(fr);
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = "true";
j.initialize();
j.transports.file.maxSize = 0;
j.transports.file.resolvePathFn = (s, e) => {
  var o;
  let t = s.electronDefaultDir;
  t || (t = s.libraryDefaultDir);
  let r = /* @__PURE__ */ new Date(), n = r.getFullYear() + (r.getMonth() + 1).toString().padStart(2, "0") + r.getDate().toString().padStart(2, "0");
  return v.join(t, `${(o = e == null ? void 0 : e.variables) == null ? void 0 : o.processType}_${n}.log`);
};
Object.assign(console, j);
const ur = v.dirname(he(import.meta.url));
process.env.APP_ROOT = v.join(ur, "..");
const N = process.env.VITE_DEV_SERVER_URL, Tr = v.join(process.env.APP_ROOT, "dist-electron"), oe = v.join(process.env.APP_ROOT, "dist");
process.env.VITE_PUBLIC = N ? v.join(process.env.APP_ROOT, "public") : oe;
let f;
function ie() {
  f = new H({
    icon: v.join(process.env.VITE_PUBLIC, "logo.png"),
    width: 1200,
    height: 700,
    // icon: path.join(__static, 'logo.png'),
    webPreferences: {
      // preload: path.join(__dirname, 'preload.mjs'),
      nodeIntegration: !0,
      contextIsolation: !1,
      // 允许img标签访问本地图片
      webSecurity: !1,
      spellcheck: !1
    }
  }), f.setMenuBarVisibility(!1), f.webContents.on("did-finish-load", () => {
    f == null || f.webContents.send("main-process-message", (/* @__PURE__ */ new Date()).toLocaleString());
  }), N ? f.loadURL(N) : f.loadFile(v.join(oe, "index.html"));
}
D.on("window-all-closed", () => {
  process.platform !== "darwin" && (D.quit(), f = null);
});
D.on("activate", () => {
  H.getAllWindows().length === 0 && ie();
});
D.whenReady().then(ie);
d.handle("close-app", (s, e) => {
  f && f.close();
});
d.handle("minimize-app", (s, e) => {
  f == null || f.minimize();
});
d.handle("open-devtools", (s, e) => {
  f == null || f.webContents.openDevTools();
});
d.handle("reload", (s, e) => {
  f == null || f.reload();
});
d.handle("choose-direcotry", (s, e) => {
  f == null || f.focus();
  let t = T.showOpenDialogSync(f, {
    defaultPath: e || "",
    properties: ["openDirectory"]
  });
  return new Promise((r, n) => {
    r(t ? t[0] : null);
  });
});
d.handle("choose-file", (s, e) => {
  f == null || f.focus();
  let t = T.showOpenDialogSync(f, {
    defaultPath: e || "",
    properties: ["openFile"]
  });
  return new Promise((r, n) => {
    r(t ? t[0] : null);
  });
});
d.handle("save-file", (s, e) => {
  if (!f) return;
  f.focus();
  let t = T.showSaveDialogSync(f, {
    defaultPath: e || ""
  });
  return new Promise((r, n) => {
    r(t || null);
  });
});
d.handle("open-path", (s, e) => G.openPath(e));
d.handle("show-item-in-folder", (s, e) => G.showItemInFolder(e));
export {
  Tr as MAIN_DIST,
  oe as RENDERER_DIST,
  N as VITE_DEV_SERVER_URL
};
